home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
lang
/
PPCsmalltalk.lha
/
PPCSmallTalk
/
parser
/
lex.yy.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-10-19
|
18KB
|
1,037 lines
/* # include "stdio.h" */
# define U(x) x
# define NLSTATE yyprevious=YYNEWLINE
# define BEGIN yybgin = yysvec + 1 +
# define INITIAL 0
# define YYLERR yysvec
# define YYSTATE (yyestate-yysvec-1)
# define YYOPTIM 1
# define YYLMAX 200
# define output(c) putc(c,yyout)
# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
# define yymore() (yymorfg=1)
# define ECHO fprintf(yyout, "%s",yytext)
# define REJECT { nstr = yyreject(); goto yyfussy;}
int yyleng; extern char yytext[];
int yymorfg;
extern char *yysptr, yysbuf[];
int yytchar;
FILE *yyin = {stdin}, *yyout = {stdout};
extern int yylineno;
struct yysvf {
int yystoff;
struct yysvf *yyother;
int *yystops;};
struct yysvf *yyestate;
extern struct yysvf yysvec[], *yybgin;
/*
Little Smalltalk lexical analyzer
*/
# include <math.h>
# undef input
# undef unput
double atof();
int linenum = 1;
# define YYNEWLINE 10
yylex(){
int nstr; extern int yyprevious;
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:
{;}
break;
case 2:
{linenum++;}
break;
case 3:
{readcomment();}
break;
case 4:
{return(ASSIGN);}
break;
case 5:
{return(ASSIGN);}
break;
case 6:
{return(lexsave(CLASS));}
break;
case 7:
{yylval.p = selfvar; return(PSEUDO);}
break;
case 8:
{yylval.p = procvar; return(PSEUDO);}
break;
case 9:
{yylval.p = supervar; return(PSEUDO);}
break;
case 10:
{yylval.p = nilvar; return(PSEUDO);}
break;
case 11:
{yylval.p = truevar; return(PSEUDO);}
break;
case 12:
{yylval.p = falsevar; return(PSEUDO);}
break;
case 13:
{yylval.p = smallvar; return(PSEUDO);}
break;
case 14:
{yylval.i = yytext[1]; return(LITCHAR);}
break;
case 15:
{return(PS);}
break;
case 16:
{return(lexsave(LITFNUM));}
break;
case 17:
{yylval.i = atoi(yytext); return(LITNUM);}
break;
case 18:
{return(lexsave(LITFNUM));}
break;
case 19:
{char c; unput(c = input());
if (c == '\'') yymore();
else return(lexlstr());}
break;
case 20:
{return(varlex());}
break;
case 21:
{return(slexsave(COLONVAR));}
break;
case 22:
{return(slexsave(LITSYM));}
break;
case 23:
{return(lexsave(MINUS));}
break;
case 24:
{return(LP);}
break;
case 25:
{return(RP);}
break;
case 26:
{return(LB);}
break;
case 27:
{return(RB);}
break;
case 28:
{return(PERIOD);}
break;
case 29:
{return(lexsave(MBAR));}
break;
case 30:
{return(lexsave(MBAR));}
break;
case 31:
{return(lexsave(BAR));}
break;
case 32:
{return(lexsave(BAR));}
break;
case 33:
{return(SEMI);}
break;
case 34:
{return(lexsave(UPARROW));}
break;
case 35:
{return(lexsave(PE));}
break;
case 36:
{return(lexsave(BINARY));}
break;
case 37:
{return(PRIMITIVE);}
break;
case -1:
break;
default:
fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */
static int ocbuf = 0;
static int pbbuf[400];
static int input()
{ int c;
if (ocbuf) {c = pbbuf[--ocbuf]; }
else {
c = getc(fp);
if (c == EOF) c = 0;
}
return(c);
}
static unput(c)
char c;
{
if (c) pbbuf[ocbuf++] = c;
}
# include <ctype.h>
static readcomment()
{ char c;
while ((c = input()) && c != '\"')
if (c == '\n') linenum++;
if (!c) yyerror("unterminated comment");
}
char *walloc(s) char *s;
{ char *p, *malloc();
p = malloc((unsigned) (strlen(s) + 1));
if (p == (char *) 0) yyerror("out of variable string space");
strcpy(p, s);
return(p);
}
static int slexsave(type)
int type;
{
yylval.c = walloc(&yytext[1]);
if (yylval.c == 0) yerr("cannot create symbol %s", yytext);
return(type);
}
static int lexsave(type)
int type;
{
yylval.c = walloc(yytext);
if (yylval.c == 0) yerr("cannot create string %s", yytext);
return(type);
}
static int varlex()
{
lexsave(0);
if (yytext[yyleng-1] == ':') return(KEYWORD);
else if (islower(yytext[0])) return(LOWERCASEVAR);
else return(UPPERCASEVAR);
}
static int lexlstr()
{ char *p, *q;
yylval.c = p = walloc(&yytext[1]);
*(p + yyleng -2) = '\0';
return(LITSTR);
}
int yyvstop[] = {
0,
36,
0,
1,
0,
2,
0,
1,
36,
0,
32,
36,
0,
3,
36,
0,
15,
36,
0,
36,
0,
36,
0,
24,
36,
0,
25,
36,
0,
23,
36,
0,
28,
36,
0,
17,
18,
20,
0,
36,
0,
33,
36,
0,
36,
0,
35,
36,
0,
20,
0,
20,
0,
26,
36,
0,
27,
36,
0,
34,
36,
0,
20,
0,
20,
0,
20,
0,
20,
0,
31,
36,
0,
30,
32,
36,
0,
29,
31,
36,
0,
22,
0,
14,
0,
19,
0,
20,
0,
20,
0,
20,
0,
21,
0,
4,
0,
5,
0,
20,
0,
20,
0,
20,
0,
20,
0,
20,
0,
20,
0,
20,
0,
18,
0,
18,
20,
0,
16,
20,
0,
20,
0,
20,
0,
10,
20,
0,
20,
0,
20,
0,
20,
0,
20,
0,
18,
0,
16,
0,
20,
0,
20,
0,
20,
0,
7,
20,
0,
20,
0,
20,
0,
11,
20,
0,
16,
0,
16,
20,
0,
6,
20,
0,
12,
20,
0,
20,
0,
20,
0,
9,
20,
0,
16,
0,
20,
0,
20,
0,
20,
0,
20,
0,
20,
0,
20,
0,
20,
0,
13,
20,
0,
37,
0,
20,
0,
8,
20,
0,
0};
# define YYTYPE char
struct yywork { YYTYPE verify, advance; } yycrank[] = {
0,0, 0,0, 1,3, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 1,4, 1,5,
0,0, 0,0, 1,6, 4,4,
0,0, 0,0, 0,0, 4,4,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 1,7, 1,8,
1,9, 1,10, 4,4, 0,0,
1,11, 1,12, 1,13, 0,0,
1,3, 0,0, 1,14, 1,15,
19,43, 1,16, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 1,17,
1,18, 1,19, 0,0, 1,20,
0,0, 0,0, 1,21, 0,0,
1,22, 0,0, 0,0, 65,53,
0,0, 65,53, 0,0, 2,31,
2,8, 2,9, 2,10, 0,0,
0,0, 9,33, 0,0, 2,13,
0,0, 0,0, 0,0, 2,14,
2,15, 9,0, 9,0, 0,0,
1,23, 9,33, 1,24, 1,25,
0,0, 0,0, 1,21, 26,46,
2,17, 2,18, 2,19, 1,26,
2,20, 45,58, 0,0, 27,47,
49,62, 2,22, 22,45, 1,27,
9,0, 46,59, 47,60, 19,44,
1,28, 1,29, 29,51, 9,33,
9,0, 9,0, 10,34, 9,33,
28,48, 1,30, 9,0, 44,57,
9,33, 48,61, 10,34, 10,0,
28,49, 2,23, 10,34, 2,24,
2,25, 50,63, 51,64, 52,65,
28,50, 11,35, 57,70, 58,71,
2,26, 9,33, 59,72, 61,73,
62,74, 11,35, 11,35, 63,75,
2,27, 11,35, 64,76, 70,81,
71,82, 2,28, 2,29, 72,83,
10,34, 10,34, 67,68, 73,84,
10,34, 74,85, 2,32, 75,86,
78,77, 10,34, 81,88, 9,0,
84,89, 85,90, 88,91, 89,92,
90,93, 9,33, 91,94, 11,36,
11,35, 92,95, 93,96, 11,35,
94,97, 95,98, 10,34, 96,99,
11,35, 37,52, 37,52, 37,52,
37,52, 37,52, 37,52, 37,52,
37,52, 37,52, 37,52, 97,100,
98,101, 39,53, 101,102, 39,53,
0,0, 11,35, 39,54, 39,54,
39,54, 39,54, 39,54, 39,54,
39,54, 39,54, 39,54, 39,54,
0,0, 67,77, 10,34, 16,37,
0,0, 16,16, 16,16, 16,16,
16,16, 16,16, 16,16, 16,16,
16,16, 16,16, 16,16, 16,38,
0,0, 0,0, 0,0, 0,0,
0,0, 11,35, 16,21, 16,21,
16,21, 16,21, 16,21, 16,21,
16,21, 16,21, 16,21, 16,21,
16,21, 16,21, 16,21, 16,21,
16,21, 16,21, 16,21, 16,21,
16,21, 16,21, 16,21, 16,21,
16,21, 16,21, 16,21, 16,21,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 16,21, 16,21,
16,21, 16,21, 16,39, 16,21,
16,21, 16,21, 16,21, 16,21,
16,21, 16,21, 16,21, 16,21,
16,21, 16,21, 16,21, 16,40,
16,21, 16,21, 16,21, 16,21,
16,21, 16,21, 16,21, 16,21,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 0,0, 0,0,
0,0, 17,42, 0,0, 0,0,
0,0, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17,41, 17,41, 17,41,
17,41, 17